
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.bdxh.clientstudentandroid.R
import com.bdxh.clientstudentandroid.bean.help.HelpCatalogBean
import com.bdxh.clientstudentandroid.bean.help.StarHelpTipsBean


class HelpCatalogSubAdapter(context: Context): BaseAdapter() {

    val mList = arrayListOf<HelpCatalogBean>()
    var context: Context?= null
    var layoutInflater : LayoutInflater?= null

    init {
        this.context = context
        layoutInflater = LayoutInflater.from(context)
    }
    
    override fun getCount() = mList.size

    override fun getItem(position: Int): HelpCatalogBean = mList[position]

    override fun getItemId(position: Int): Long = position.toLong()

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var viewHolder:ViewHolder ?= null
        var convertViewTmp = convertView
        if (convertViewTmp == null) {
            convertViewTmp = layoutInflater?.inflate(R.layout.[layoutname], parent, false)
            viewHolder = ViewHolder(convertViewTmp)
            convertViewTmp?.tag = viewHolder
        } else {
            viewHolder = convertViewTmp.tag as ViewHolder
        }
        viewHolder.bindData(getItem(position))
        return convertViewTmp!!
    }
	
	fun setData(list: List<HelpCatalogBean>?) {
        mList.clear()
        list?.let {
            mList.addAll(list)
        }
        notifyDataSetChanged()
    }
    
    class ViewHolder(itemView:View?) {
[declare_statement]    
        init {
[init_view_statement]  }

        fun bindData(bean: HelpCatalogBean) {
            txt_title?.text = bean.title
        }
    }
}